package org.example.mall.admin.model.entity.manage;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 菜单权限表
 * </p>
 *
 * @author hzq
 * @since 2021-12-29
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("menu")
@ApiModel(value = "Menu对象", description = "菜单权限表")
public class Menu extends Model<Menu> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "菜单ID")
    @TableId(value = "menu_id", type = IdType.AUTO)
    private Integer menuId;

    @NotBlank(message = "菜单名称不能为空")
    @ApiModelProperty(value = "菜单名称")
    @TableField("`name`")
    private String name;

    @ApiModelProperty(value = "权限标识")
    @TableField("permission")
    private String permission;

    @ApiModelProperty(value = "路由地址/组件地址")
    @TableField("path")
    private String path;

    @NotNull(message = "父菜单ID不能为空")
    @ApiModelProperty(value = "父菜单ID")
    @TableField("parent_id")
    private Integer parentId;

    @ApiModelProperty(value = "菜单图标")
    @TableField("icon")
    private String icon;

    @ApiModelProperty(value = "排序值")
    @TableField("`sort`")
    private Integer sort;

    @ApiModelProperty(value = "是否缓存（1是0否）")
    @TableField("keep_alive")
    private String keepAlive;

    @NotBlank(message = "菜单类型不能为空")
    @ApiModelProperty(value = "菜单类型（0左菜单1按钮2顶菜单）")
    @TableField("type")
    private String type;

    @ApiModelProperty(value = "创建时间")
    @TableField("create_time")
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private LocalDateTime createTime;

    @ApiModelProperty(value = "更新时间")
    @TableField("update_time")
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private LocalDateTime updateTime;

    @ApiModelProperty(value = "是否删除（1是0否）", hidden = true)
    @TableField("del")
    @TableLogic
    @JsonIgnore
    private String del;

    @NotBlank(message = "客户端id不能为空")
    @ApiModelProperty(value = "客户端id")
    @TableField("client_id")
    private String clientId;

    @ApiModelProperty(value = "版本")
    @TableField("version")
    @Version
    private Integer version;


    @Override
    protected Serializable pkVal() {
        return this.menuId;
    }

}
